package com.hmkj.admin.controller.user;

import com.hmkj.admin.controller.BaseController;
import com.hmkj.admin.controller.GenericController;
import com.hmkj.common.entity.dtgrid.DtGrid;
import com.hmkj.core.model.user.UserIdentifyModel;
import com.hmkj.core.po.userIdentify.UserIdentify;
import com.hmkj.core.service.userIdentify.UserIdentifyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping(BaseController.BASE_URI)
public class UserIdentifyJsonController extends GenericController<Integer, UserIdentify> {
    @Resource
    private UserIdentifyService userIdentifyService;

    /**
     * 实名认证列表json数据
     */
    @ResponseBody
    @RequestMapping(value = "userIdentify/list.json", method = RequestMethod.POST)
    @RequiresPermissions("sys:auth:list")
    public DtGrid listJson(String dtGridPager) throws Exception {
        dtGridPager = dataAuthority(dtGridPager);
        return userIdentifyService.getDtGridList(dtGridPager, UserIdentifyModel.class);
    }

    /**
     * 审核
     */
//    @ResponseBody
//    @RequestMapping(value = "/userAuth/json/verify")
//    @RequiresPermissions("sys:real:audit")
//    public ResultEntity refuse(UserIdentify userIdentify) throws Exception {
//        UserIdentify identify = userIdentifyService.selectOne(new UserIdentify(u -> {
//            u.setId(userIdentify.getId());
//            u.setDelFlag(UserIdentify.DELFLAG.NORMAL.code);
//        }));
//        if (null == identify) {
//            throw new BussinessException("该认证信息不存在");
//        } else if (identify.getStatus() != UserIdentify.STATUS.T1.code) {
//            throw new BussinessException("当前状态下不能操作");
//        }
//        userIdentifyService.updateByPrimaryKeySelective(new UserIdentify(u -> {
//            u.setId(userIdentify.getId());
//            u.setStatus(userIdentify.getStatus());
//            u.setRemark(userIdentify.getRemark());
//            u.setVerifyTime(DateUtils.getNow());
//        }));
//        return ok();
//    }

}
